package main

import (
	"os"
	"fmt"
	"net"
	"io"
)

func main()  {
	server:="localhost:5555"
	tcpAddr,_:=net.ResolveTCPAddr("tcp",server)
	tcpconn,_:=net.DialTCP("tcp",nil,tcpAddr)
	defer tcpconn.Close()
	//读取文件
	filename:="/home/xiaonu/Desktop/aa.png"
	file1,_:=os.Open(filename)

	dataBytes:=make([]byte,1024)
	for{
		n,err:=file1.Read(dataBytes)
		if err==io.EOF {
			fmt.Println("文件已经发送完成")
			file1.Close()
			break
		}
		fmt.Println(dataBytes[:n])
		n,_=tcpconn.Write(dataBytes[:n])
	}
}
